<template>
  <el-form :inline="true" :model="formInline" class="form-inline">
    <el-row class="row">
      <el-form-item label="工单描述：">
        <el-input
          v-model="formInline.remark"
          placeholder="--请输入--"
        ></el-input>
      </el-form-item>
      <el-form-item label="工单类型：" prop="type">
        <el-select v-model="formInline.type" placeholder="--请选择--">
          <el-option
            v-for="item in worktypeDrop"
            :key="item.code"
            :label="item.value"
            :value="item.code"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="起止时间：">
        <el-date-picker
          v-model="date"
          type="datetimerange"
          format="YYYY-MM-DD HH:mm:ss"
          value-format="YYYY-MM-DD HH:mm:ss"
          start-placeholder="开始时间"
          range-separator="~"
          end-placeholder="结束时间"
          @change="dateChange"
          size="small"
        />
      </el-form-item>
      <el-form-item class="btns">
        <el-button type="primary" @click="onSubmit">查询</el-button>
        <el-button type="success" class="m-left" @click="onClear"
          >清空</el-button
        >
      </el-form-item>
    </el-row>
  </el-form>
</template>

<script setup>
import { reactive, defineEmits, ref, onMounted } from 'vue'
import { commonworktyprDrop } from '@/api/back'
const formInline = reactive({
  remark: '', //工单描述
  type: '', //工单类型
  time: '' //起止时间
})
const date = ref([])
const emits = defineEmits(['onSearch'])
const onSubmit = () => {
  emits('onSearch', formInline)
}
const onClear = () => {
  formInline.remark = ''
  formInline.type = ''
  formInline.time = '' //起止时间
  date.value = []
  emits('onSearch', formInline)
}
const dateChange = (date) => {
  console.log('dateChange', date)
  formInline.time = date
}
const worktypeDrop = ref([]) //工单类型下拉列表
//工单类型下拉
const GetworkType = () => {
  commonworktyprDrop({
    code: '',
    type: 6
  }).then((res) => {
    let data = res
    worktypeDrop.value = [...data]
  })
}
onMounted(() => {
  GetworkType() //工单类型
})
</script>

<style lang="scss" scoped>
.form-inline {
  width: 100%;
  position: relative;
  // display: flex;
  // column-gap: 20px;
  // padding-bottom: 33px;
  // margin-top: -5px;
  .row {
    display: flex;
    flex-wrap: wrap;
    column-gap: 4%;
  }
  .btns {
    position: absolute;
    right: 0;
    top: 4px;
    .m-left {
      margin-left: 20px;
    }
  }
}
:deep(.el-range-editor--small .el-range-separator) {
  line-height: 30px;
}
</style>
